From 0601ff4fe6b26df7c4d7b7181d9e487617853441 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Wed, 17 Jul 2013 03:20:24 +0000 Subject: [PATCH] Get rid of a few more explicit microsecond accesses. Add GPX test for wild and crazy times. --- gpsbabel/garmin.cc | 3 +-- gpsbabel/reference/bigtime.gpx | 17 +++++++++++++++++ gpsbabel/tef_xml.cc | 8 ++++---- gpsbabel/testo.d/gpx.test | 4 ++++ 4 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 gpsbabel/reference/bigtime.gpx diff --git a/gpsbabel/garmin.cc b/gpsbabel/garmin.cc index fda06a80f..30724c66b 100644 --- a/gpsbabel/garmin.cc +++ b/gpsbabel/garmin.cc @@ -705,8 +705,7 @@ pvt2wpt(GPS_PPvt_Data pvt, waypoint* wpt) pvt->tow - pvt->leap_scnds; wptimes = floor(wptime); - wpt->creation_time = wptimes; - wpt->microseconds = 1000000.0 * (wptime - wptimes); + wpt->SetCreationTime(wptimes, 1000000.0 * (wptime - wptimes)); /* * The Garmin spec fifteen different models that use a different diff --git a/gpsbabel/reference/bigtime.gpx b/gpsbabel/reference/bigtime.gpx new file mode 100644 index 000000000..3a1c476c9 --- /dev/null +++ b/gpsbabel/reference/bigtime.gpx @@ -0,0 +1,17 @@ + + + + + + + Early + Early + Early + + + + Late + Late + Late + + diff --git a/gpsbabel/tef_xml.cc b/gpsbabel/tef_xml.cc index 550d0d058..cdb65735c 100644 --- a/gpsbabel/tef_xml.cc +++ b/gpsbabel/tef_xml.cc @@ -200,8 +200,8 @@ waypoint_final() return; } - via = wpt_tmp->microseconds; - wpt_tmp->microseconds = 0; + via = wpt_tmp->wpt_flags.fmt_use ; + wpt_tmp->wpt_flags.fmt_use = 0; if (version < 2) { /* keep the old behaviour */ wpt_tmp->notes = wpt_tmp->description; @@ -252,7 +252,7 @@ tef_item_start(const char *args, const char **attrv) wpt_tmp = waypt_new(); if ((waypoints == 1) || (waypoints == item_count)) { - wpt_tmp->microseconds++; + wpt_tmp->wpt_flags.fmt_use ++; } while (*avp) { @@ -262,7 +262,7 @@ tef_item_start(const char *args, const char **attrv) wpt_tmp->description = trimmed_strdup(avp[1]); } else if ((0 == case_ignore_strcmp(avp[0], "ViaStation")) && (0 == case_ignore_strcmp(avp[1], "true"))) { - wpt_tmp->microseconds = 1; /* only a flag */ + wpt_tmp->wpt_flags.fmt_use = 1; /* only a flag */ } /* new in TEF V2 */ diff --git a/gpsbabel/testo.d/gpx.test b/gpsbabel/testo.d/gpx.test index 0c74668a2..e4fd6b5f3 100644 --- a/gpsbabel/testo.d/gpx.test +++ b/gpsbabel/testo.d/gpx.test @@ -21,3 +21,7 @@ compare ${REFERENCE}/basecamp~gpx.gpx ${TMPDIR}/basecamp~gpx.gpx rm -f ${TMPDIR}/extensiondata.gpx gpsbabel -i unicsv -f ${REFERENCE}/extensiondata.unicsv -x transform,trk=wpt -o gpx,garminextensions -F ${TMPDIR}/extensiondata.gpx compare ${REFERENCE}/extensiondata~unicsv.gpx ${TMPDIR}/extensiondata.gpx + +# Read, write GPX file with times that don't fit in time_t, subsecond. +gpsbabel -i gpx -f ${REFERENCE}/bigtime.gpx -o gpx -F ${TMPDIR}/bigtime.gpx +compare ${REFERENCE}/bigtime.gpx ${TMPDIR}/bigtime.gpx -- 2.30.2